// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import API from './API'

// ============================== 导出异步调用 ============================== //

export default {
  // —————————————————————————————— 信息 —————————————————————————————— //

  async remoteInfo({ state }) {
    const inOut = await API.getInOut(state.infoParam.inOut)
    const result = await API.getResult(state.infoParam.result)
    const type = await API.getType(state.infoParam.type)
    return { inOut, result, type }
  },

  // —————————————————————————————— 列表 —————————————————————————————— //

  async remoteList({ state: { param } }) {
    const [num, arr] = await API.getList(param)
    return [num, transList(arr)]
  },
}

// ============================== 转换方法 ============================== //

const transList = (arr) => {
  arr.forEach((item) => {
    item.img = CORE.image(item.vehiclePicUrl)
  })
  return arr
}
